var React = require('react-native');
var {
  View,
  Text,
  StyleSheet
} = React;


/**
 * badge组件
 */
class Badge extends React.Component {
  render() {
    var count = this.props.count > 99 ? '99+' : this.props.count;

    return (
      <View style={[styles.container, this.props.style]}>
        <Text style={styles.text}>{count}</Text>
      </View>
    );
  }
}


var styles = StyleSheet.create({
  container: {
    borderLeftWidth: 2,
    borderRightWidth: 2,
    backgroundColor: 'red',
    position: 'absolute',
    borderRadius:6,
    paddingLeft: 2,
    paddingRight: 2,
    justifyContent: 'center',
    alignItems: 'center',
    top: -2,
    right:-12
  },
  text: {
    color: '#FFF',
    fontSize: 10
  }
});


module.exports = Badge;
